<template>
  <el-dialog :visible.sync="visible" v-dialogDrag :title="title" class="tl-dialog" width="1200px" @open="open" @close="close" top="10px" :append-to-body="true" :modal-append-to-body="true">
    <div style="padding-bottom:10px">
      <!-- 查询界面 -->
      <tl-list-search ref="search" :query-param="queryParam" @search="doQuery" :isDisplayDefaultSearch="false">
        <template slot="search">
          <el-form-item label="编码" prop="code">
            <el-input v-model="queryParam.qry_code" placeholder=""></el-input>
          </el-form-item>
          <el-form-item label="名称">
            <el-input v-model="queryParam.qry_name" placeholder=""></el-input>
          </el-form-item>
        </template>
      </tl-list-search>
      <!-- 列表界面 -->
      <div>
        <!-- 列表选择 -->
        <div class="table-alert-div" ref="selector">
          <el-alert type="success" :closable="false" class="tl-table-alert-info" effect="light">
            <template slot="title">
              已选择&nbsp;<a class="tl-table-alert-info-a1">{{ selectedRows.length }}</a
              >项&nbsp;&nbsp;
              <a class="tl-table-alert-info-a2" @click="doClearSelected">全部清空</a>
            </template>
          </el-alert>
        </div>
        <!--表格渲染-->
        <el-table class="tl-table" ref="mainTable" :height="tableHeight" v-loading="loading" :data="datas" @selection-change="doSelectChange" @sort-change="doSortChange" @row-dblclick="doRowDbClick" row-key="id" border fit :row-class-name="doChangeRowClassName">
          <el-table-column type="selection" width="55px" fixed="left" v-if="isSingleSelect === false "> </el-table-column>
					<el-table-column prop="projectid" label="项目id" width="150px" sortable="custom" sort-by="projectid" align="center" header-align="center"></el-table-column>
					<el-table-column prop="projectcode" label="项目编号" width="150px" sortable="custom" sort-by="projectcode" align="center" header-align="center"></el-table-column>
					<el-table-column prop="projectnumber" label="项目实际编号" width="150px" sortable="custom" sort-by="projectnumber" align="center" header-align="center"></el-table-column>
					<el-table-column prop="projectmanager" label="项目经理" width="150px" sortable="custom" sort-by="projectmanager" align="center" header-align="center"></el-table-column>
					<el-table-column prop="projectmanagercode" label="项目经理工号" width="150px" sortable="custom" sort-by="projectmanagercode" align="center" header-align="center"></el-table-column>
					<el-table-column prop="projectlevel" label="项目级别" width="150px" sortable="custom" sort-by="projectlevel" align="center" header-align="center"></el-table-column>
					<el-table-column prop="projectname" label="项目名称" width="150px" sortable="custom" sort-by="projectname" align="center" header-align="center"></el-table-column>
					<el-table-column prop="projectdefaultlevel" label="项目默认级别" width="150px" sortable="custom" sort-by="projectdefaultlevel" align="center" header-align="center"></el-table-column>
					<el-table-column prop="levelhistory" label="项目级别变更历史" width="150px" sortable="custom" sort-by="levelhistory" align="center" header-align="center"></el-table-column>
					<!-- <el-table-column prop="projecttype" label="项目类型" width="150px" sortable="custom" sort-by="projecttype" align="center" header-align="center"></el-table-column> -->
					<el-table-column prop="bidcycle" label="项目周期" width="150px" sortable="custom" sort-by="bidcycle" align="center" header-align="center"></el-table-column>
					<el-table-column prop="planstartdate" label="计划开始日期" width="170px" sortable="custom" sort-by="planstartdate" align="center" header-align="center" :formatter="dateTimeFormat"></el-table-column>
					<el-table-column prop="planenddate" label="计划结束日期" width="170px" sortable="custom" sort-by="planenddate" align="center" header-align="center" :formatter="dateTimeFormat"></el-table-column>
					<el-table-column prop="finishdate" label="立项完成日期" width="170px" sortable="custom" sort-by="finishdate" align="center" header-align="center" :formatter="dateTimeFormat"></el-table-column>
					<el-table-column prop="actualenddate" label="实际结项日期" width="170px" sortable="custom" sort-by="actualenddate" align="center" header-align="center" :formatter="dateTimeFormat"></el-table-column>
					<el-table-column prop="endtype" label="结项类型" width="150px" sortable="custom" sort-by="endtype" align="center" header-align="center"></el-table-column>
					<el-table-column prop="currentmilepost" label="当前里程碑" width="150px" sortable="custom" sort-by="currentmilepost" align="center" header-align="center"></el-table-column>
					<el-table-column prop="currentmilepoststate" label="当前里程碑状态" width="150px" sortable="custom" sort-by="currentmilepoststate" align="center" header-align="center"></el-table-column>
					<el-table-column prop="abnormalstate" label="项目异常状态" width="150px" sortable="custom" sort-by="abnormalstate" align="center" header-align="center"></el-table-column>
					<el-table-column prop="abnormalreason" label="项目异常原因" width="150px" sortable="custom" sort-by="abnormalreason" align="center" header-align="center"></el-table-column>
					<el-table-column prop="sponsor" label="Sponsor" width="150px" sortable="custom" sort-by="sponsor" align="center" header-align="center"></el-table-column>
					<el-table-column prop="sponsorcode" label="Sponsor工号" width="150px" sortable="custom" sort-by="sponsorcode" align="center" header-align="center"></el-table-column>
					<el-table-column prop="owner" label="Owner" width="150px" sortable="custom" sort-by="owner" align="center" header-align="center"></el-table-column>
					<el-table-column prop="ownercode" label="Owner工号" width="150px" sortable="custom" sort-by="ownercode" align="center" header-align="center"></el-table-column>
					<el-table-column prop="dispdeptcommoncode1" label="申请部门2" width="100px" sortable="custom" sort-by="deptcommoncode1" align="center" header-align="center"></el-table-column>
					<el-table-column prop="background" label="项目背景" width="150px" sortable="custom" sort-by="background" align="center" header-align="center"></el-table-column>
					<el-table-column prop="target" label="项目目标" width="150px" sortable="custom" sort-by="target" align="center" header-align="center"></el-table-column>
					<el-table-column prop="projectstate" label="项目状态" width="150px" sortable="custom" sort-by="projectstate" align="center" header-align="center"></el-table-column>
					<el-table-column prop="achievements" label="项目成果" width="150px" sortable="custom" sort-by="achievements" align="center" header-align="center"></el-table-column>
					<el-table-column prop="importance" label="项目概述" width="150px" sortable="custom" sort-by="importance" align="center" header-align="center"></el-table-column>
					<el-table-column prop="competitor" label="主要竞争对手" width="150px" sortable="custom" sort-by="competitor" align="center" header-align="center"></el-table-column>
					<el-table-column prop="competitoranaly" label="竞争对手分析" width="150px" sortable="custom" sort-by="competitoranaly" align="center" header-align="center"></el-table-column>
					<el-table-column prop="summary" label="总结性评估" width="150px" sortable="custom" sort-by="summary" align="center" header-align="center"></el-table-column>
					<el-table-column prop="orgname" label="所属组织" width="150px" sortable="custom" sort-by="orgname" align="center" header-align="center"></el-table-column>
					<el-table-column prop="orgcode" label="所属组织编码" width="150px" sortable="custom" sort-by="orgcode" align="center" header-align="center"></el-table-column>
					<el-table-column prop="deptname" label="所属部门" width="150px" sortable="custom" sort-by="deptname" align="center" header-align="center"></el-table-column>
					<el-table-column prop="deptcode" label="所属部门编码" width="150px" sortable="custom" sort-by="deptcode" align="center" header-align="center"></el-table-column>
					<el-table-column prop="linetype" label="子表类型" width="150px" sortable="custom" sort-by="linetype" align="center" header-align="center"></el-table-column>
					<el-table-column prop="applyorgname" label="申请公司" width="150px" sortable="custom" sort-by="applyorgname" align="center" header-align="center"></el-table-column>
					<el-table-column prop="applyorgcode" label="申请公司编码" width="150px" sortable="custom" sort-by="applyorgcode" align="center" header-align="center"></el-table-column>
					<el-table-column prop="applydeptname" label="申请部门" width="150px" sortable="custom" sort-by="applydeptname" align="center" header-align="center"></el-table-column>
					<el-table-column prop="applydeptcode" label="申请部门编码" width="150px" sortable="custom" sort-by="applydeptcode" align="center" header-align="center"></el-table-column>
					<el-table-column prop="applydate" label="申请日期" width="170px" sortable="custom" sort-by="applydate" align="center" header-align="center" :formatter="dateTimeFormat"></el-table-column>
					<el-table-column prop="username" label="申请人姓名" width="120px" sortable="custom" sort-by="username" align="center"></el-table-column>
					<el-table-column prop="usercode" label="申请人工号" width="150px" sortable="custom" sort-by="usercode" align="center" header-align="center"></el-table-column>
					<el-table-column prop="docdate" label="单据日期" width="170px" sortable="custom" sort-by="docdate" align="center" header-align="center" :formatter="dateTimeFormat"></el-table-column>
					<el-table-column prop="dispstate" label="状态" width="100px" sortable="custom" sort-by="state" align="center" header-align="center"></el-table-column>
					<el-table-column prop="description" label="备注" min-width="250px" align="left" header-align="center"></el-table-column>
					<el-table-column prop="enabled" label="有效" width="100px" sortable="custom" sort-by="enabled" align="center" header-align="center">
						<template slot-scope="scope">
							<el-tag v-if="scope.row.enabled === 1" type="success">是</el-tag>
							<el-tag v-else type="danger">否</el-tag>
						</template>
					</el-table-column>
					<el-table-column prop="schedulestate" label="进度状态" width="150px" sortable="custom" sort-by="schedulestate" align="center" header-align="center"></el-table-column>
					<el-table-column prop="changelevelreason" label="项目级别调整原因" width="150px" sortable="custom" sort-by="changelevelreason" align="center" header-align="center"></el-table-column>
					<el-table-column prop="reminddate" label="消息提醒时间" width="170px" sortable="custom" sort-by="reminddate" align="center" header-align="center" :formatter="dateTimeFormat"></el-table-column>
					<el-table-column prop="version" label="版本号" width="150px" sortable="custom" sort-by="version" align="center" header-align="center"></el-table-column>
          <el-table-column label="操作" width="80px" align="center" fixed="right" v-if="isSingleSelect === true">
            <template slot-scope="scope">
              <el-button type="text" icon="el-icon-finished" @click="doSelectData(scope.row[fieldDefaultKey])">选择</el-button>
            </template>
          </el-table-column>
        </el-table>
        <!-- 列表分页 -->
        <el-row class="pagebar" ref="pager">
          <el-pagination @size-change="doChangeSize" @current-change="doChangeIndex" :current-page="pageInfo.currentPage" :page-sizes="pageInfo.pageSizes" :total="pageInfo.totalCount" layout="total, sizes, prev, pager, next, jumper" background class="tl-table-pagination"> </el-pagination>
        </el-row>
      </div>
    </div>
    <div slot="footer" class="dialog-footer" v-if="isSingleSelect === false">
      <el-button type="text" @click="doCancelEdit">取消</el-button>
      <el-button type="primary" @click="doConfirm">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
/** mixins */
import { mixin_ref_list } from '@tapui/mixins/mixin_ref_list'
/** 子组件 */
/** 工具类 */
import { queryDataCode } from '@tapui/api/dataCode'
import { getAction, putAction, postAction } from '@tapui/utils/http'
/** VUE配置 */
export default {
  name: 'TlSdProjectHistoryRef',
  components: {},
  mixins: [mixin_ref_list],
  data() {
    return {
      description: 'SD项目立项-历史表参照页面',
      // 默认Key字段名
      fieldDefaultKey: 'id',
      // 默认显示字段名
      fieldDefaultValue: 'name',
      // url配置
      url: {
        list: '/sd/projectHistory/refList'
      },
      // 排序参数
      sorterInfo: {
        sidx: 'sortcode',
        sord: 'asc'
      }
    }
  },
  methods: {}
}
</script>

